<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/images/custom/favicon.ico?v=5.1.0" />






<meta name="description" content="一名不知所措的IT从业者">
<meta name="keywords" content="html,js,jquery,node.js,开发者,编程,运维,运维开发">
<meta property="og:type" content="website">
<meta property="og:title" content="Change The World">
<meta property="og:url" content="http://www.zhangxiaoheng.cn/index.html">
<meta property="og:site_name" content="Change The World">
<meta property="og:description" content="一名不知所措的IT从业者">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Change The World">
<meta name="twitter:description" content="一名不知所措的IT从业者">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://www.zhangxiaoheng.cn/"/>





  <title>Change The World</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Change The World</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">沉默是一种力量</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/08/14/javascript-regexp/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/08/14/javascript-regexp/" itemprop="url">javascript正则篇</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-14T20:22:45+08:00">
                2017-08-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/javascript/" itemprop="url" rel="index">
                    <span itemprop="name">javascript</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <blockquote>
<p>    俗语说的好 “好记性，不如烂笔头”，所以思来想去还是把这篇博客完成吧！本篇主要介绍javascript的正则表达式，ok 闲话少说，下面就直接开始，GO GO GO …</p>
</blockquote>
<p><red><em>注：正则表达式就是对字符串的操作</em></red></p>
<hr>
<h2>正则表达式语法</h2>
<p>    创建正则表达式有两种表达方式，一种就是非常规范的 <code>new</code> 方式，另一种就是Perl风格的表达式。说不上谁好谁坏，各有各的优缺点。 就看您的喜好了🤔</p>
<ul>
<li>
<p><code>new RegExp(pattern,option);</code></p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">pattern: 字符串，指定了正则表达式的模式用于匹配字符串</div><div class="line">option: 可选值，主要有 g、i、 m</div><div class="line">============</div><div class="line">g: 全局匹配 </div><div class="line">i: 忽略大小写</div><div class="line">m: 多行匹配</div><div class="line">============</div></pre></td></tr></table></figure>
<p>    一眼看上去很容易理解，构造一个新的实例对象，按照我们正常的思路创建了一个正则表达式。它返回一个新的 RegExp 对象，具有指定的模式和标志，如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">var reg = new RegExp(’\\d&#123;2&#125;’,’g’);</div></pre></td></tr></table></figure>
<p>可<code>看</code>而知：<br>
优点： 容易理解<br>
缺点： 😷（机智如我）</p>
</li>
</ul>
<p><red><em>注：使用new创建正则表达式时使用元字符如（“<code>\d</code>”）必须要添加转义字符 “<code>\</code>”</em></red></p>
<ul>
<li>
<p><code>perl</code> 风格表示:</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/pattern/option #没错，就这么多</div></pre></td></tr></table></figure>
<p>再次可<code>看</code>而知：<br>
优点： 写起来非常简单<br>
缺点： 😵 （已瞎）</p>
</li>
</ul>
<hr>
<h2>修饰符</h2>
<table>
<thead>
<tr>
<th>option</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td>g</td>
<td style="text-align:center">全局匹配         (<code>global</code>)</td>
</tr>
<tr>
<td>i</td>
<td style="text-align:center">匹配时忽略大小写 (<code>ignoreCase</code>)</td>
</tr>
<tr>
<td>m</td>
<td style="text-align:center">多行匹配        (<code>multiline</code>)</td>
</tr>
</tbody>
</table>
<p><red><em>注:m  使用时，只有匹配字符串中包含\n，并且正则表达式中包含^或$行首行尾，m 修饰符才会生效</em></red></p>
<h2>‌中括号[ ]</h2>
<table>
<thead>
<tr>
<th>表达式</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td>[asd]</td>
<td style="text-align:center">匹配中括号中的任意字符</td>
</tr>
<tr>
<td>[^asd]</td>
<td style="text-align:center">匹配除了中括号中的任意字符</td>
</tr>
<tr>
<td>指定范围</td>
<td style="text-align:center"></td>
</tr>
<tr>
<td>[a-z0-9]</td>
<td style="text-align:center">匹配a到z，0到9的任意字符</td>
</tr>
<tr>
<td>分块匹配</td>
<td style="text-align:center"></td>
</tr>
<tr>
<td>(abc|def|ghi)</td>
<td style="text-align:center">匹配指定的选项</td>
</tr>
</tbody>
</table>
<h2>‌元字符</h2>
<table>
<thead>
<tr>
<th>‌元字符</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td>.</td>
<td style="text-align:center">匹配单个字符，不包括换行和行结束符</td>
</tr>
<tr>
<td>\d</td>
<td style="text-align:center">匹配数字</td>
</tr>
<tr>
<td>\D</td>
<td style="text-align:center">匹配非数字字符</td>
</tr>
<tr>
<td>\w</td>
<td style="text-align:center">匹配单词字符，a-z0-9A-Z以及下划线</td>
</tr>
<tr>
<td>\w</td>
<td style="text-align:center">匹配非单词字符</td>
</tr>
<tr>
<td>\s</td>
<td style="text-align:center">匹配空白字符，空格符，制表符，回车符，换行符，垂直换行符，       换页符</td>
</tr>
<tr>
<td>\S</td>
<td style="text-align:center">匹配非空白字符</td>
</tr>
<tr>
<td>\b</td>
<td style="text-align:center">匹配单词边界，单词开头或结尾</td>
</tr>
<tr>
<td>\B</td>
<td style="text-align:center">匹配非单词边界</td>
</tr>
<tr>
<td>\0</td>
<td style="text-align:center">匹配null字符</td>
</tr>
<tr>
<td>\n</td>
<td style="text-align:center">匹配换行符</td>
</tr>
<tr>
<td>\f</td>
<td style="text-align:center">匹配换页符</td>
</tr>
<tr>
<td>\r</td>
<td style="text-align:center">匹配回车符</td>
</tr>
<tr>
<td>\t</td>
<td style="text-align:center">匹配制表符</td>
</tr>
<tr>
<td>\v</td>
<td style="text-align:center">匹配垂直制表符</td>
</tr>
<tr>
<td>\xxx</td>
<td style="text-align:center">八进制</td>
</tr>
<tr>
<td>\xdd</td>
<td style="text-align:center">16进制</td>
</tr>
<tr>
<td>\uxxxx</td>
<td style="text-align:center">16进制规定的Unicode字符</td>
</tr>
</tbody>
</table>
<h2>‌量词</h2>
<table>
<thead>
<tr>
<th>‌量词</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td>+</td>
<td style="text-align:center">匹配至少一个[1，+∞]</td>
</tr>
<tr>
<td>*</td>
<td style="text-align:center">匹配零个或多个[0，+∞]</td>
</tr>
<tr>
<td>?</td>
<td style="text-align:center">匹配零个或一个[0，1]</td>
</tr>
<tr>
<td>{n}</td>
<td style="text-align:center">匹配n个的序列字符串</td>
</tr>
<tr>
<td>{n，m}</td>
<td style="text-align:center">匹配n个的序列字符，最多匹配m次</td>
</tr>
<tr>
<td>{n，}</td>
<td style="text-align:center">匹配至少n个序列字符串</td>
</tr>
<tr>
<td>n$</td>
<td style="text-align:center">匹配任何n字符结尾</td>
</tr>
<tr>
<td>^n</td>
<td style="text-align:center">匹配任何n字符开头的字符</td>
</tr>
<tr>
<td>?=n</td>
<td style="text-align:center">匹配任何其后紧接指定字符串n的字符串</td>
</tr>
<tr>
<td>?！=n</td>
<td style="text-align:center">匹配任何其后没有紧接指定字符串n的字符</td>
</tr>
</tbody>
</table>
<h2>‌<code>regexp</code>方法</h2>
<table>
<thead>
<tr>
<th>‌方法</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>compile</code></td>
<td style="text-align:center">编译正则表达式</td>
</tr>
<tr>
<td><code>exec</code></td>
<td style="text-align:center">检索指定值返回值及其位置</td>
</tr>
<tr>
<td><code>test</code></td>
<td style="text-align:center">检索指定值，返回TRUE或FALSE</td>
</tr>
</tbody>
</table>
<h2>‌<code>string</code>支持正则的方法</h2>
<table>
<thead>
<tr>
<th>‌方法</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>search</code></td>
<td style="text-align:center">检索正则表达式匹配的值</td>
</tr>
<tr>
<td><code>match</code></td>
<td style="text-align:center">找到一个或多个正则表达式匹配</td>
</tr>
<tr>
<td><code>replace</code></td>
<td style="text-align:center">替换与正则表达式匹配的字符串</td>
</tr>
<tr>
<td><code>split</code></td>
<td style="text-align:center">分割字符串为数组</td>
</tr>
</tbody>
</table>
<h2>示例展示</h2>
<table>
<thead>
<tr>
<th>‌方法</th>
<th style="text-align:center">概述</th>
</tr>
</thead>
<tbody>
<tr>
<td>手机号码匹配</td>
<td style="text-align:center">/^1[34578]\d{9}$/ 或 /^1(3|4|5|7|8)\d{9}$/</td>
</tr>
</tbody>
</table>
<p>😴困了，待续…</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/07/22/showmacbook/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/07/22/showmacbook/" itemprop="url">拆开它</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-22T15:35:54+08:00">
                2017-07-22
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/computer/" itemprop="url" rel="index">
                    <span itemprop="name">computer</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2>上篇</h2>
<p>    最近小弟做了一个艰难的决定 ☺ ，接下来的即将面临着一段相对艰难的日子。不用多疑，因为买了人生中的第一台macbook pro,凭心而讲这个决定其实很早之前就已经萌生了，记得当时正在学习<a href="https://developer.apple.com/swift/" title="swift" target="_blank" rel="external">swift</a>（Apple新出来的开发语言，也不怎么新了），也就是在2016年10月份左右，当时刚毕业没有多久，在第一家公司需要Apple应用开发人员，顺势便开始了我的Apple之路。<br>
    当时因为身上并没有什么闲钱（吃喝还是可以的），想买一台mac，⊙﹏⊙‖∣ 只是想想而已，但是脚步并未有放弃，我把自己的<a href="http://www.gateway.com/gw/zh/CN/content/home" title="gateway官网" target="_blank" rel="external">gateway</a>笔记本装了一个黑苹果，哎！装上是可以的但让人头痛的是合适的驱动太难找了，目前我的黑苹果无线网卡驱动，电池驱动还没有着落…<br>
<img src="/2017/07/22/showmacbook/hpg.png" alt="微博记录"><br>
    抒情就此打住，下面就来看看今天（2017年7月22日）刚买到的macbook pro吧，在此感谢弟兄们的推荐以及苹果的叶子客服给与的讲解与解惑，更是要感谢快递小哥在炎炎的夏日能够准时的送达，你们辛苦了，都不容易相互尊重，相互理解。</p>
<h2>下篇</h2>
<p>    下面我们开始上图了，步入正规<sub>拆开它</sub></p>
<ul>
<li>
<p>快递包装(顺风)<br>
<img src="/2017/07/22/showmacbook/baozhuanghe.jpg" alt="快递包装"><br>
并没有多大看头，和普通快递差不多</p>
</li>
<li>
<p>下面揭掉l庐山第一层面纱<br>
<img src="/2017/07/22/showmacbook/dym.jpg" alt="庐山第一面"></p>
</li>
<li>
<p>庐山第二面<br>
<img src="/2017/07/22/showmacbook/dem.jpg" alt="庐山第二面"><br>
正面一如既往的logo,反面有六颗螺钉</p>
</li>
<li>
<p>内部装置<br>
<img src="/2017/07/22/showmacbook/zz.jpg" alt="装置"></p>
</li>
<li>
<p>下面就是正常的系统预设，就简单的放几张新功能,Touch ID<br>
<img src="/2017/07/22/showmacbook/dsm.jpg" alt="庐山第三面"><br>
在最新的macbook上加入了指纹解锁</p>
</li>
<li>
<p>指纹支付<br>
<img src="/2017/07/22/showmacbook/dsim.jpg" alt="庐山第四面"><br>
剁手党们你准备好了吗</p>
</li>
<li>
<p>Touch Bar<br>
<img src="/2017/07/22/showmacbook/dwm.jpg" alt="庐山第五面"><br>
逼格满满有木有</p>
</li>
<li>
<p>最后主界面压脚<br>
<img src="/2017/07/22/showmacbook/dlm.jpg" alt="庐山第五面"></p>
</li>
</ul>
<h2>结束</h2>
<p>梦想 奋斗 坚持</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/07/09/life20170709/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/07/09/life20170709/" itemprop="url">星期的一天</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-09T20:53:41+08:00">
                2017-07-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p><strong><code>水一篇...</code></strong></p>
<h2>上午</h2>
<p>    早上起来已是八点半左右，看了最长的电影指环王，经过几天的努力（😏）只剩下四五十分钟左右，大概看完了有二十分钟左右就开始报幕仔细看了一下竟然有二十多分钟左右。真是😥<br>
    赶紧起床洗漱完毕，戴上耳机骑着电动车，一路向东，去之前的房东阿姨那里，当然是为了押金。<br>
    时间很快大约十一点左右到达目的地，事情当然办的很顺利（主要是有合同在手），和房东阿姨寒暄了几句，拿了钱，赶紧撤了，随后骑车直奔银行找了附近的邮政储蓄，结果可想而知，尴尬没有办过邮政的卡，算了直奔地铁站，上了地铁，把钱通过某宝发给了兄弟们，完事。<br>
    最头痛的是，竟然会多坐了一站路，所以说，做事还是用心点是没有错的，马上掉头，来到了指定地点，开始换乘四号线直达紫金山登山一号口。<br>
    时间大约在11点二十左右，开始一步一步的登山，时间在跑当然我却在走登山的阶梯，……差不多五十分钟左右过去了(没办法，身体素质好歇了好几次)😊<br>
    十二点一刻左右最终抵达了山顶，俗话说得好，尽吾志也而不能至者，可以无悔矣。<br>
‌这句看着怎么这么别扭呢，还是换一句吧，你所走的路，只为更好的风景（绝对不是卖弄）😆</p>
<h2>中午</h2>
<p>    <br>
表示一直在下山的路上（因为选择了另外一条下山的道路）‌</p>
<h2>下午</h2>
<p>    <br>
表示一直在回去路上…</p>
<h2>晚上</h2>
<p>    <br>
敲了几行代码，还是洗洗睡吧😴，明天还要上班呢.</p>
<h2>END</h2>
<p>直接上图，今天的紫金山（风真的很大…）<br>
<img src="/2017/07/09/life20170709/PicsArt_07-09-09.30.32.jpg" alt="紫金山"></p>
<p>励志一下吧&lt;你已经输在了起跑线&gt;<br>
<img src="/2017/07/09/life20170709/beb664c4-b1b2-43b4-ae5b-2e276e8cfd9a.jpg" alt="编程"></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/06/26/shell-seconds/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/06/26/shell-seconds/" itemprop="url">内置变量SECONDS小记</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-26T20:13:15+08:00">
                2017-06-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1>前言</h1>
<p><strong>How time flies!</strong><br>
记得刚开始开通<code>blog</code>的时候，当时还是处于无业游民的状态。曾经心中默默地下过一个决心，每周写一篇技术博客。当写到这里的时候也是对自己一通唏嘘。</p>
<p>自从找到新工作到现在差不多有三个月的时间了，曾经的决心依然无存了……最终还是败给了工作和懒惰。每当翻起<code>blog</code>就会再次激起我的决定，那就是 <code>go on……</code></p>
<p>闲话少说，开始继续技术之旅吧，本次重新写技术博客就写一个简单易懂的吧，太难得也不会哈哈哈……</p>
<h1>正文</h1>
<h2>SECONDS</h2>
<p>是一个shell脚本的内置环境变量，通过这个变量可以获取到行<code>shell</code>脚本运行的时间，【以秒为单位】:<br>
一言不合先来个示例以表尊敬:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/bash  </span></div><div class="line">cat ＜＜eof   </div><div class="line">		this is a simple example:</div><div class="line">		this will shows the script running <span class="built_in">times</span></div><div class="line">		thank you <span class="built_in">read</span> the blog.</div><div class="line">eof</div><div class="line">sleep 5</div><div class="line"><span class="built_in">echo</span> -E <span class="string">'\E[1,31,40m'</span> <span class="string">"The shell script file <span class="variable">$(basename $0)</span> Running time is <span class="variable">$SECONDS</span>"</span> tput sgr0</div></pre></td></tr></table></figure>
<p>俗话说得好，字不如表，表不如图，怎能不来张图呢：<br>
<img src="/2017/06/26/shell-seconds/2017-06-26_22-08-41.png" alt="result"><br>
这个变量也是蛮给力的最起码省去你的几行代码，好了本篇就到这里落笔了，哦是关机了<br>
记住初心，默默前行。<br>
<strong>change the world.</strong></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/03/26/blog-study/" itemprop="url">blog搭建小记</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-26T12:55:15+08:00">
                2017-03-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <blockquote>
<p>    在IT界混下去没有blog怎么能行呢？<br>
以上纯属玩笑，因为有了<code>blog</code>可以记录下平时生活的点点滴滴也可以分享下相关技术心得更可以记录工作中遇到的问题。多说不宜，那就开始步入整体吧，此次<code>blog</code>搭建主要是采用 <code>hexo + githup</code>, 下面就 <code>follow me</code> 一起按照步骤开始开启blog之旅吧。</p>
</blockquote>
<h3>准备工作</h3>
<ol>
<li>如果你想对外可以访问，首先申请<a href="https://github.com/" title="github" target="_blank" rel="external"><code>github</code></a>帐号</li>
<li>新建仓库，命名格式: <code>用户名.githup.io</code> 点击完成，如下图:</li>
</ol>
<p><img src="/2017/03/26/blog-study/io.png" alt="仓库名称"></p>
<p>目前完成了万里长征的第一步,<code>go on...</code></p>
<h3>安装<code>blog</code>环境‌</h3>
<ul>
<li>安装<a href="https://nodejs.org/en/" title="NODE.JS" target="_blank" rel="external"><code>node.js</code>官网</a>，<a href="http://nodejs.cn/download/" title="node.js" target="_blank" rel="external">中文网</a>，用于生成静态页面</li>
</ul>
<ol start="2">
<li>安装<a href="https://git-scm.com/" title="git" target="_blank" rel="external"><code>git</code></a>,网盘（windows）<a href="http://pan.baidu.com/s/1pKXcpi7" title="git" target="_blank" rel="external">安装包</a>,安装git主要是把hexo生成的blog站点提交到github</li>
<li>全局安装 <code>hexo</code></li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install -g hexo --save</div></pre></td></tr></table></figure>
<ol start="4">
<li>新建站点文件夹（以下没有特别说明均在此文件夹下执行），进行初始化</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo init</div></pre></td></tr></table></figure>
<ol start="5">
<li>生成<code>blog</code>静态页面</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate （或 hexo g）</div></pre></td></tr></table></figure>
<ol start="6">
<li>本地启动，进行预览</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server （或 hexo s）</div></pre></td></tr></table></figure>
<p><code>blog</code>站点预览地址：<a href="http://localhost:4000" title="预览" target="_blank" rel="external">http://localhost:4000</a></p>
<h3>配置<code>Github</code></h3>
<ul>
<li>修改站点文件夹下的<code>_config.yml</code>文件，找到<code>deploy</code>位置，修改如下：</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">deploy: </div><div class="line">  <span class="built_in">type</span>: git </div><div class="line">  repository: https://github.com/zzhtom/zzhtom.github.io.git  </div><div class="line">  branch: master</div></pre></td></tr></table></figure>
<ul>
<li>安装<code>git</code>部署的插件</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install hexo-deployer-git --save</div></pre></td></tr></table></figure>
<ul>
<li>部署到<code>github</code></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy (或 hexo d)</div></pre></td></tr></table></figure>
<ul>
<li><code>hexo</code> 常用命令</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">hexo clean                清理生成的blog页面    </div><div class="line">hexo generate             生成静态页面  </div><div class="line">hexo deploy               部署页面到github  </div><div class="line">hexo new <span class="string">"postName"</span>       新建文章  </div><div class="line">hexo new page <span class="string">"pageName"</span>  新建页面  </div><div class="line">hexo server               开启本地服务  </div><div class="line">hexo <span class="built_in">help</span>                 查看帮助  </div><div class="line">hexo version              查看Hexo的版本</div></pre></td></tr></table></figure>
<h3>配置域名访问</h3>
<ul>
<li>注册域名，如<a href="https://wanwang.aliyun.com/" title="阿里云" target="_blank" rel="external">阿里云</a>、<a href="https://dnspod.qcloud.com/?from=qcloudHome" title="腾讯云" target="_blank" rel="external">腾讯云</a></li>
<li>进行域名解析设置</li>
</ul>
<p><img src="/2017/03/26/blog-study/anly.png" alt="域名解析"></p>
<ul>
<li>进行<code>ip</code>指向，<code>ip</code>为<code>github</code>访问路径的解析<code>ip</code>,如下图：</li>
</ul>
<p><img src="/2017/03/26/blog-study/ip.png" alt="ip地址"></p>
<ul>
<li>进行域名指向，指向域名即为 <code>用户名.github.io</code></li>
</ul>
<h3>网站推荐</h3>
<p><a href="https://hexo.io/" title="hexo" target="_blank" rel="external"><code>hexo</code>官网</a><br>
<a href="http://theme-next.iissnan.com/" title="next" target="_blank" rel="external"><code>Next</code>主题</a><br>
<a href="http://baixin.io/2015/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/" title="blog" target="_blank" rel="external">博客推荐</a><br>
本人<a href="http://www.zhangxiaoheng.cn" title="blog"><code>blog</code></a> <a href="http://www.zhangxiaoheng.cn" title="blog">www.zhangxiaoheng.cn</a> 欢迎来访</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/custom/ava.jpg"
               alt="Tom" />
          <p class="site-author-name" itemprop="name">Tom</p>
           
              <p class="site-description motion-element" itemprop="description">一名不知所措的IT从业者</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/zzhtom" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/2958802633" target="_blank" title="Weibo">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  Weibo
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.jianshu.com/u/806a589bd7f0" target="_blank" title="简书">
                  
                    <i class="fa fa-fw fa-book"></i>
                  
                  简书
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tom</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
    <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  
    

    
  





  






  





  

  

  

  

  

  

</body>
</html>
